package 第三周;

import java.util.Scanner;
public class 猜数游戏 {
    public static void main(String[] args) {
        int number = (int) (Math.random() * 100);
        int min = 0;
        int max = 100;
        int guess;
        int a=1;

        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入"+min+"到"+max);
            guess = sc.nextInt();
            if (guess == number) {
                System.out.println("你猜对了");
                break;
            } else if (guess < number) {
                System.out.println("猜小了");
                min=guess+1;
            } else if (guess > number) {
                System.out.println("猜大了");
                max=guess-1;
            }
            a++;
            System.out.println("循环数是"+a);
        }
    }
}